package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {

    @Select("select count(*) from emp")
    Long count();

    @Select("select * from emp limit #{start} , #{pageSize}")
    List<Emp> list(Integer start, Integer pageSize);


     Page<Emp> page(String name, Short gender, LocalDate begin, LocalDate end);


    void add(Emp emp);

    @Select("select id, username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time " +
            "from emp " +
            "where id = #{id}")
    Emp fistById(Integer id);



    void update(Emp emp);


    @Delete("delete  from emp  where id = #{id}")
    void daleteById(Integer id);


    @Select("select id,username,password,name,gender,image,job,entrydate,dept_id,create_time,update_time " +
            "from emp where username = #{username} and password = #{password}")
    Emp getbByUsernameAndPassword(Emp emp);


    @Delete("delete from  emp  where dept_id  = #{deptId}")
    void deleteByDeptId(Integer deptId);
}






